package in.muton.edushare.panels;

import java.util.ArrayList;
import java.util.List;

import org.apache.wicket.PageParameters;
import org.apache.wicket.markup.html.basic.Label;
import org.apache.wicket.markup.html.link.BookmarkablePageLink;
import org.apache.wicket.markup.html.panel.Panel;
import org.apache.wicket.model.IModel;
import org.apache.wicket.model.Model;

import com.edushare.common.util.URLUtils;

public class SearchURLPanel extends Panel {

	private static final long serialVersionUID = 2846644823288279467L;

	public SearchURLPanel(String id, IModel<ArrayList<String>> model, String urlTxt) {
		super(id, model);
		PageParameters params = new PageParameters();
		List<String> par = model.getObject();
		int i=0;
		for(String param: par){
			params.add(""+i, URLUtils.escapeSplChars(param));
			i++;
		}
		BookmarkablePageLink<Void> link = new BookmarkablePageLink<Void>(
																	"url",
																	in.muton.edushare.pages.search.SearchPage.class,
																	params);
		add(link);
		link.add(new Label("text", urlTxt).setRenderBodyOnly(true));
	}
	
	public SearchURLPanel(String id, String param, String urlTxt) {
		super(id, new Model<String>(param));
		PageParameters params = new PageParameters();
		params.add("0", URLUtils.escapeSplChars(param));
		BookmarkablePageLink<Void> link = new BookmarkablePageLink<Void>(
																	"url",
																	in.muton.edushare.pages.search.SearchPage.class,
																	params);
		add(link);
		link.add(new Label("text", urlTxt).setRenderBodyOnly(true));
	}

}
